﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using BLL;
using DAL;
using EDM;

namespace Utility
{
    public class Factory
    {
        public static T SearchTnfo<T>()
        {
            T repositoryObject = default(T);
            string dataGetWay = System.Configuration.ConfigurationManager.AppSettings["DAL"];           

            if (dataGetWay == "ADO.NET")
            {
                if (typeof(T) == typeof(IStatusShow))
                {
                    IStatusShow tempRepository = (IStatusShow)new StatusShow();
                    repositoryObject = (T)tempRepository;
                }

                if (typeof(T) == typeof(IAuthorityShow))
                {
                    IAuthorityShow tempRepository = (IAuthorityShow)new AuthorityShow();
                    repositoryObject = (T)tempRepository;
                }

                if (typeof(T) == typeof(IRoleSearch))
                {
                    IRoleSearch tempRepository = (IRoleSearch)new RoleSearch();
                    repositoryObject = (T)tempRepository;
                }


            }
             if (dataGetWay == "EF")
            {
                if (typeof(T) == typeof(IStatusShow))
                {
                    IStatusShow tempRepository = (IStatusShow)new StatusQuery();
                    repositoryObject = (T)tempRepository;
                }

                if (typeof(T) == typeof(IAuthorityShow))
                {
                    IAuthorityShow tempRepository = (IAuthorityShow)new AuthorityQuery();
                    repositoryObject = (T)tempRepository;
                }

                if (typeof(T) == typeof(IRoleSearch))
                {
                    IRoleSearch tempRepository = (IRoleSearch)new RoleQuery();
                    repositoryObject = (T)tempRepository;
                }

            }

            return repositoryObject;
        }
    }
}
